import React from 'react'
import {useDispatch, useSelector} from 'react-redux'
import { Button, Cell, CellGroup,Checkbox } from 'react-vant'
import { switchPerson } from '../../store/module/person'
import { useNavigate } from 'react-router-dom'
function Index() {
    //获取仓库数据
    const list = useSelector(state=>state.person.personList)
  
    const dispatch = useDispatch()
    const navigate=useNavigate()
  return (
    <div>
       {/* 渲染数据 */}
       <CellGroup>
          {
             list.map((v)=>{
                return <Cell key={v.id} 
                title={
                    <div style={{display:'flex'}}>
                       
                        <Checkbox 
                        onClick={()=>dispatch(switchPerson(v))} 
                        checked={v.state}
                        >
                         
                        </Checkbox>

                        {v.name}-{v.code}
                    </div>
                }
                >

                </Cell>
             })
          }
       </CellGroup>
   

       <Button block round type='primary' onClick={()=>navigate(-1)}>确定</Button>
    </div>
  )
}

export default Index
